/***************************************************
This program generates Figure 4
******************************************************/


/* Analysis of bias by Major */
include "./config.do"
log using "./06.02.cip_graphs_$date.log", replace
import delimited "$supportdir/bias_scatter_cip_byyear.csv", clear 

gen str40 cip_lab = ""
replace cip_lab = "Agriculture" if cip==1
replace cip_lab = "Architecture" if cip==4
replace cip_lab = "Area, ethnic, cultural, gender studies" if cip==5
replace cip_lab = "Communication and journalism" if cip==9
replace cip_lab = "Computer and information sciences" if cip==11
replace cip_lab = "Educaton" if cip==13
replace cip_lab = "Engineering" if cip==14
replace cip_lab = "Engineering technology" if cip==15
replace cip_lab = "Foreign language, literatures, and linguistics" if cip==16
replace cip_lab = "Family and consumer sciences" if cip==19
replace cip_lab = "Legal professions" if cip==22
replace cip_lab = "English" if cip==23
replace cip_lab = "Liberal arts and sciences" if cip==24
replace cip_lab = "Biology" if cip==26
replace cip_lab = "Mathematics and statistics" if cip==27
replace cip_lab = "Parks, recreation, leisure, fitness" if cip==31
replace cip_lab = "Philosophy and religious studies" if cip==38
replace cip_lab = "Physical sciences" if cip==40
replace cip_lab = "Security and protective services" if cip==43
replace cip_lab = "Public administration and social service" if cip==44
replace cip_lab = "Social sciences" if cip==45
replace cip_lab = "Visual and performing arts" if cip==50
replace cip_lab = "Health professions" if cip==51
replace cip_lab = "Business, management, marketing" if cip==52
replace cip_lab = "History" if cip==54




gen bias = beta_out - beta_in 

bysort cip: egen n_out_cip = total(n_out)

table cip year_post [aw=n_out] , c(mean bias) col row 

table cip, c(sum n_out) col row

table cip year_post [aw=n_missing] , c(mean beta_missing) col row 

table cip year_post if state == 48 | state ==8 [aw=n_out] , c(mean bias) col row 

graph hbar (mean) bias (mean) beta_missing [aw = n_out] if (n_out_cip > 2000), over(cip_lab , sort((mean) bias) label(labsize(*.5)) ) legend(label(1 "Bias") label (2 "Difference in No Earnings"))
graph export "$resultsdir/bias_by_major_$date.png", replace 


